#ifndef PROCESSOR_FACTORY_H_
#define PROCESSOR_FACTORY_H_

#include <unistd.h>
#include <exception>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <thrift/protocol/TProtocol.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TDebugProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/THttpServer.h>
#include <thrift/TProcessor.h>
#include <glog/logging.h>
#include "gen-cpp/ChatService.h"
#include "server/ChatServiceServerProcessor.h"

namespace at = apache::thrift;
namespace atp = apache::thrift::protocol;
namespace att = apache::thrift::transport;


namespace server {

  class ProcessorFactory : public at::TProcessorFactory {
  public:
    boost::shared_ptr<at::TProcessor> getProcessor(const at::TConnectionInfo& connInfo) {
      LOG(INFO) << "new connection";
      boost::shared_ptr<chat::ChatServiceIf> iface(new chat::ChatServiceServerHandler());
      return boost::shared_ptr<at::TProcessor>(new ChatServiceServerProcessor(iface));
    }
  };
}

#endif
